package com.king.service;

import com.google.gson.JsonObject;
import com.king.config.GlobalConst;
import com.king.utils.CommonUtils;

public class WxMenuService {

    private static final String CREATE_MENU_URL = GlobalConst.getConfig("MP_CREATE_MENU_URL");

    /**
     * 创建自定义菜单
     *
     * @param data 菜单数据
     * @return
     */
    public static boolean createCustomMenu(String data) {
        String accessToken = WxTokenService.getAccessToken();
        String url = CREATE_MENU_URL.replace("ACCESS_TOKEN", accessToken);
        String result = CommonUtils.post(url, data);

        JsonObject jsonObject = GlobalConst.gson.fromJson(result, JsonObject.class);
        String errCode = jsonObject.get("errcode").getAsString();
        return errCode.equals("0");
    }
}
